package com.jiyi.activity.datainput;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.jiyi.activity.datainput.jm.JMAddMainActivity;
import com.jiyi.activity.datainput.jm.JMDataViewActivity;
import com.jiyi.activity.datainput.sm.SMAddMainActivity;
import com.jiyi.activity.datainput.sm.SMDataViewActivity;
import com.swift.maintenance.R;
import com.swift.maintenance.utils.UserInfoUtil;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 高层调查区域选择
 * Created by Administrator on 2018/3/30.
 */

public class DataInputZoneFragment extends Fragment {


    @BindView(R.id.tvBack)
    TextView tvBack;
    @BindView(R.id.tvTitle)
    TextView tvTitle;
    @BindView(R.id.tvSearch)
    TextView tvSearch;
    @BindView(R.id.tvSM)
    TextView tvSM;
    @BindView(R.id.tvJM)
    TextView tvJM;

    public View onCreateView(LayoutInflater inflater,
                             @Nullable ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_datainput_zone, null, false);
        ButterKnife.bind(this, view);
        init();
        return view;
    }

    private void init() {
        setTop();
    }

    private void setTop() {
        tvBack.setVisibility(View.GONE);
        tvTitle.setText("高层建筑消防安全");
        tvSearch.setVisibility(View.GONE);
    }

    @OnClick({R.id.tvSM, R.id.tvJM})
    public void onClick(View view) {
        Intent intent;
        switch (view.getId()) {
            case R.id.tvSM:
                if (UserInfoUtil.getCurrentUserAcessRole() == 2) {
                    // 录入员
                    intent = new Intent(getContext(), SMAddMainActivity.class);
                    startActivity(intent);
                } else {
                    // 其他
                    intent = new Intent(getContext(), SMDataViewActivity.class);
                    startActivity(intent);
                }

                break;
            case R.id.tvJM:
                if (UserInfoUtil.getCurrentUserAcessRole() == 2) {
                    // 录入员
                    intent = new Intent(getContext(), JMAddMainActivity.class);
                    startActivity(intent);
                } else {
                    intent = new Intent(getContext(), JMDataViewActivity.class);
                    startActivity(intent);
                }
                break;

            default:
                break;
        }
    }


}
